from django.contrib.auth.decorators import user_passes_test


def url_permission_required(perm_codename):
    def check_perm(user):
        return user.has_perm(f'account.{perm_codename}')
    return user_passes_test(check_perm)


# 视图使用示例
# @url_permission_required('access_account_page')
# def sensitive_operation(request):
#     ...
